package main

import (
	"os"
	"sync"

	"github.com/ldlw/wfrp/src/models/client"
	"github.com/ldlw/wfrp/src/utils/log"
)

func main() {
	err := client.LoadConf("../../../conf/wrpc.ini")
	if err != nil {
		log.Warn("wrpc.ini not found or error!")
		os.Exit(-1)
	}

	log.InitLog(client.LogWay, client.LogFile, client.LogLevel)

	// wait until all control goroutine exit
	var wait sync.WaitGroup
	wait.Add(len(client.ProxyClients))

	for _, client := range client.ProxyClients {
		go ControlProcess(client, &wait)
	}

	log.Info("Start wrpc success")
	wait.Wait()
	log.Warn("All proxy exit!")
}
